/**
 * http://usejsdoc.org/
 */
var log4js = require('log4js');

const logger = log4js.getLogger('cheese');
logger.level = 'debug';
Object.defineProperty(global, '__stack', {
	  get: function(){
	    var orig = Error.prepareStackTrace;
	    Error.prepareStackTrace = function(_, stack){ return stack; };
	    var err = new Error;
	    Error.captureStackTrace(err, arguments.callee);
	    var stack = err.stack;
	    Error.prepareStackTrace = orig;
	    return stack;
	  }
});

Object.defineProperty(global, '__line', {
  get: function(){
    return __stack[2].getLineNumber();
  }
});
Object.defineProperty(global, '__file', {
	  get: function(){
	    return __stack[2].getFileName().split('/').slice(-1)[0];
	  }
	});

global.log=function(str){
	
	logger.debug(__file+":"+__line+"\n"+JSON.stringify(str,null,4));
}
global.logObj=function(str){
	var keys=Object.keys(str);
	var str1="";
	keys.forEach(function (item) {
		str1+=item+":"+str[item].toString();
	});
	
	logger.debug(__file+":"+__line+"\n"+str1);
}
global.assert=function (b,str) {
	if(!b)logger.debug(__file+":"+__line+"\n"+str);
}
